app.controller('commentController', function($scope,$http ,$controller,$sce,$rootScope) {
	$controller('baseController' , {$scope:$scope});
	$scope.status = 0;
	
	//搜索 分页
    $scope.comment= {};
    $scope.comment.status = $scope.status;
	$scope.search=function(page, rows){
		$http.post('../comment/search.do?page='+page+'&rows='+rows,$scope.comment).success(
			function(response){
				console.log(response,'评论列表');
				$scope.commentslist=response.rows;	//显示当前页数据
				$scope.paginationConf.totalItems=response.total;	//更新总记录数	
			}		
		);
	}
	
	
    //删除  批量删除  全选
    $scope.allSelection =function($event){
    	if($event.target.checked){
        	var _checkbox = $("tbody").find("[type='checkbox']").not("[disabled]");
        	_checkbox.each(function () {
        		$(this).prop("checked",true);
        		$scope.selectIds.push($(this).attr("id"));

            });    				   					
		 }else{
			 $scope.selectIds = [];
			 var _checkbox = $("tbody").find("[type='checkbox']").not("[disabled]");
        	_checkbox.each(function () {
        		$(this).prop("checked",false);
            });
		}
    	console.log($scope.selectIds,'全选')
    }
    
  //确定删除
    $scope.deleteByArr = function(){
    	console.log($scope.selectIds);
    	if($scope.selectIds.length > 0){
    		//询问框
    		layer.confirm('确定要删除？', {
    		  btn: ['确定','取消'] //按钮
    		}, function(){
    	        $http.post('../comment/deleteCommentByIdArray.do',$scope.selectIds).success( function (res){
    	      	  console.log(res,'批量刪除');
    	      	  if(res.success){
    	      		layer.msg(res.message,function(){
    	      			self.location.reload();
    	      		},{icon: 1});	
    	      	  }else{
    	      		layer.msg(res.message); 
    	      	  }
    	          }); 
    		  
    		}, function(){
    			layer.msg('已取消删除',{icon:2});
    		});
    	}else{
    		layer.msg('未选择任何选项',{icon:2});
    	}

    }
	
})